﻿using System;
using System.Reflection;

namespace RealDolmen.Helpers
{
    public class WrapperType
    {
        private Type type;

        public WrapperType(Type type)
        {
            this.type = type;
        }

        public object Invoke(string method)
        {
            MethodInfo mi = type.GetMethod(method, BindingFlags.Static | BindingFlags.NonPublic, null, new Type[0], null);

            // Simply invoking the method and passing parameters
            // The null parameter is the object to call the method from. Since the method is
            // static, pass null.
            return mi.Invoke(null, null);
        }

        public object Invoke(string method, params object[] parameters)
        {
            MethodInfo mi = type.GetMethod(method, BindingFlags.Static | BindingFlags.NonPublic);
            return mi.Invoke(null, parameters);
        }
    }
}
